function fid=createReportSummary(outputPath,names,priorStru,postStru,description)
%% function createReport(outputPath,names,priorStru,postStru,description)
% 
% Create a tex report with the estimation output of the model 
% 

%% outputPath: full path to create file 

%% priorStru 
% .distribution 
% .mean
% .std
% .lowerBound 
% .upperBound 

%% postStru
% .param 
% .std 
% .logLikel
% .logPost

%% names. 
% .outputFile: name of the file 
% .model: first layer 
% .specification: second layer 
% .subfolder: third layer 
% .param

%% description 

cucd=cd; 
%% Begin Report 

%% 12.3 Table of parameters and steady state changes 

%% I. Open file 
cd(outputPath); 
fid=fopen([names.outputFile,'.tex'],'w');
cd(cucd);
cd ..;
wd=cd; 

graphFooter=regexprep([extrsubf(cucd,wd),'\\', extrsubf(outputPath,cucd)],filesep,' '); 

%% II. Front Page with titleCell 
titleCell.A=['Model         : ',char(names.model)]; 
titleCell.B=['Specification : ',char(names.specification)]; 
titleCell.C=['Subfolder     : ',char(names.subfolder)]; 
titleCell.D=['This file     : ',char(names.outputFile),'.tex']; 
titleCell.E=regexprep(['OutputPath   : ',extrsubf(outputPath,cucd)],filesep,' ');
tempNames=fieldnames(titleCell); 
for ii=1:length(tempNames); 
    fldnm=char(tempNames{ii}); 
    titleCell.(fldnm)=regexprep(titleCell.(fldnm),'_',' '); 
    titleCell.(fldnm)=regexprep(titleCell.(fldnm),'\',' '); 
end 
clear tempNames; 

%% Write Report using reportCover.m 
reportCoverSummary(fid,'REPORT FOR MODEL',titleCell); 
clear titleCell; 
disp('Wrote Report cover');  

%% Write Description 
if exist('description','var')~=0 && isempty(description)==false; 
    fprintf(fid,'\\textbf{Description} \n'); 
    writeText2Tex(fid,description); 
end 
fprintf(fid,'%% Begin Prior Posterior Table'); 
fprintf(fid,'\\pagebreak \n'); 


%% II. Parameters using latexTableCell
matCell=[priorStru.distribution ...
    num2cprec([priorStru.mean priorStru.std  postStru.param ...
    postStru.std])]; 
colNames={'Dist','Prior Mean','Prior Std','Post Mode','Std Mode'}; 
format.rows={'$'}; 
if length(names.param) > 36 
    format.font='scriptsize'; 
end 
latexTableCell(fid,matCell,names.param,colNames,format,{'Prior Posterior Table'},...
    'Parameters','Table 1'); 
fprintf(fid,'Log Posterior = %7.4f \n',postStru.logPost ); 
fprintf(fid,'\\smallskip \n'); 
fprintf(fid,'Log Likelihood =%7.4f \n',postStru.logLikel); 
cd(cucd); 

%fclose(fid); 
